package com.bilibili.api;

import com.bilibili.domain.JsonResponse;
import com.bilibili.domain.entity.Video;
import com.bilibili.service.ElasticSearchService;
import com.bilibili.utils.FastDFSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * projectName:com.bilibili.api
 *
 * @author 飞
 * @create by 2024/6/1420:51
 * description:
 */
//@RestController
@Api(tags = "测试接口")
public class DemoController {
    @Resource
    private FastDFSUtil fastDFSUtils;

    @Resource
    private ElasticSearchService elasticSearchService;

    @GetMapping("/slices")
    public void slices(MultipartFile multipartFile) throws Exception {
        fastDFSUtils.convertFileToSlices(multipartFile);
    }

    @PostMapping("/test")
    public void test(String s){
        s="12345";
    }

    @ApiOperation("测试es")
    @GetMapping("/es-videos")
    public JsonResponse<Video> getVideo(@RequestParam String keyword){
        Video video = elasticSearchService.getVideo(keyword);
        return new JsonResponse<>(video);
    }
}
